package luj.tool.jnproxyan.proxy.network.socks.request.op;

import luj.tool.jnproxyan.proxy.network.socks.actor.root.Socks5Actor;
import luj.tool.jnproxyan.proxy.network.socks.request.SocksRequest;
import org.springframework.stereotype.Component;

import static com.google.common.base.Preconditions.checkNotNull;

@Component
public class SocksReqGetter {

  public SocksReqGetter inject(Socks5Actor actor, Long reqId) {
    var result = new SocksReqGetter();
    result._actor = actor;
    result._reqId = reqId;
    return result;
  }

  public SocksRequest getReq() {
    SocksRequest req = _actor.getRequestMap().get(_reqId);
    return checkNotNull(req, _reqId);
  }

  Socks5Actor _actor;

  Long _reqId;
}
